<template>
  <div class="student">
    <h2>我是学生，我的名字是{{name}}</h2>
    <button @click="sendStudent">点我发送我的名字给老师</button>
    <!--命名插槽-->
    <slot name="test">不传参数默认显示这文本</slot>
  </div>
</template>
<script>
export default {
  name: "StudentView",
  data(){
    return{
      name:'chy',
    }
  },
  methods:{
    sendStudent(){
      //传递学生姓名
      this.$bus.$emit('helloTeacher',this.name)
    },
  },
  mounted(){
    
  }
}
</script>
<style scoped>
.student{
  background-color: orange;
}
</style>